﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace dbPoll_Application.Models
{
    public enum ParticipantType
    {
        None = 0,
        Keypad = 1,
        Web = 2,
        Generic = 3
    }
    public class Participant
    {
        public virtual int participantID { get; set; }
        public virtual String deviceID { get; set; }
        public virtual ParticipantType type { get; set; }
        public virtual ParticipantGroup group { get; set; }
        public virtual User linkedUser { get; set; }
        public virtual Boolean attended { get; set; }
        public virtual String firstName { get; set; }
        public virtual String lastName { get; set; }
        public virtual Boolean isTestParticipant { get; set; }
        public virtual Entity entity { get; set; }
        public virtual int votingWeight { get; set; }

        public Participant()
        {
            this.participantID = -1;
            this.deviceID = "-1";
            this.type = ParticipantType.None;
            this.group = null;
            this.linkedUser = null;
            this.attended = false;
            this.firstName = String.Empty;
            this.lastName = String.Empty;
            this.isTestParticipant = false;
            this.entity = null;
            this.votingWeight = 1;
        }

        public Participant(String deviceID, ParticipantType type, String firstName, String lastName)
        {
            this.participantID = -1;
            this.deviceID = deviceID;
            this.type = type;
            this.group = null;
            this.linkedUser = null;
            this.attended = false;
            this.firstName = firstName;
            this.lastName = lastName;
            this.isTestParticipant = false;
            this.entity = null;
            this.votingWeight = 1;
        }

        public Participant(String deviceID, ParticipantType type, String firstName, String lastName, Entity entity)
        {
            this.participantID = -1;
            this.deviceID = deviceID;
            this.type = type;
            this.group = null;
            this.linkedUser = null;
            this.attended = false;
            this.firstName = firstName;
            this.lastName = lastName;
            this.isTestParticipant = false;
            this.entity = entity;
            this.votingWeight = 1;
        }

        public Participant(String deviceID, ParticipantType type, User linkedUser, String firstName, String lastName)
        {
            this.participantID = -1;
            this.deviceID = deviceID;
            this.type = type;
            this.group = null;
            this.linkedUser = linkedUser;
            this.attended = false;
            this.firstName = firstName;
            this.lastName = lastName;
            this.isTestParticipant = false;
            this.entity = null;
            this.votingWeight = 1;
        }

        public Participant(String deviceID, ParticipantType type, ParticipantGroup group, String firstName, String lastName)
        {
            this.participantID = -1;
            this.deviceID = deviceID;
            this.type = type;
            this.group = group;
            this.linkedUser = null;
            this.attended = false;
            this.firstName = firstName;
            this.lastName = lastName;
            this.isTestParticipant = false;
            this.entity = null;
            this.votingWeight = 1;
        }

        public Participant(String deviceID, ParticipantType type, ParticipantGroup group, String firstName, String lastName, Entity entity)
        {
            this.participantID = -1;
            this.deviceID = deviceID;
            this.type = type;
            this.group = group;
            this.linkedUser = null;
            this.attended = false;
            this.firstName = firstName;
            this.lastName = lastName;
            this.isTestParticipant = false;
            this.entity = entity;
            this.votingWeight = 1;
        }

        public Participant(String deviceID, ParticipantType type, ParticipantGroup group, User linkedUser, String firstName, String lastName)
        {
            this.participantID = -1;
            this.deviceID = deviceID;
            this.type = type;
            this.group = group;
            this.linkedUser = linkedUser;
            this.attended = false;
            this.firstName = firstName;
            this.lastName = lastName;
            this.isTestParticipant = false;
            this.entity = null;
            this.votingWeight = 1;
        }

        public Participant(String deviceID, ParticipantType type, User linkedUser, String firstName, String lastName, Entity entity)
        {
            this.participantID = -1;
            this.deviceID = deviceID;
            this.type = type;
            this.group = null;
            this.linkedUser = linkedUser;
            this.attended = false;
            this.firstName = firstName;
            this.lastName = lastName;
            this.isTestParticipant = false;
            this.entity = entity;
            this.votingWeight = 1;
        }

        public Participant(int participantID, String deviceID, ParticipantType type, ParticipantGroup group, User linkedUser, Boolean attended, String firstName, String lastName)
        {
            this.participantID = participantID;
            this.deviceID = deviceID;
            this.type = type;
            this.group = group;
            this.linkedUser = linkedUser;
            this.attended = attended;
            this.firstName = firstName;
            this.lastName = lastName;
            this.isTestParticipant = false;
            this.entity = null;
            this.votingWeight = 1;
        }

        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return false;
            }
            var participant = obj as Participant;
            if ((System.Object)participant == null)
            {
                return false;
            }
            return this.participantID == participant.participantID;
        }

        public override int GetHashCode()
        {
            return this.participantID;
        }
    }
}
